<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
      background-color: #fff;
    }
    .content {
      position: relative;
      width: 800px;
      height: 487px;
      border: 5px solid pink;
      margin: 50px auto;
      overflow: hidden;
    }
    h1 {
      position: absolute;
      top: 190px;
      left: 110px;
      font-size: 100px;
      color: pink;
    }
    .box {
      display: flex;
      justify-content: space-around;
      align-items: center;
      flex-wrap: wrap;
    }
    .blockage {
      display: flex;
      width: 30px;
      height: 30px;
      background-color: #e7dede;
      z-index: 1;
      border: 1px solid #fff;
    }
    .active {
      box-shadow: 0 0 10px 0 rgb(126, 204, 235),
                  0 0 20px 0 rgb(126, 192, 218),
                  0 0 30px 0 rgb(190, 225, 238);
      background-color: skyblue;
      animation: move 4s linear forwards;
      z-index: 2;
    }
    @keyframes move {
      5% {
        transform: translateY(-25px) 
      }
      100% {
        transform: translateY(625px) rotate(180deg)
      }
    }
  </style>
</head>
<body>
  <div class="content">
    <h1>Hello World</h1>
    <div class="box">
    </div>
  </div>
  <script>
    const box = document.querySelector('.box')
    // 创建若干个小方块元素，并添加到父类中
    for(let i = 0; i < 551; i++){
      const div = document.createElement('div')
      div.classList.add('blockage')
      box.appendChild(div)
    }
    // 为父类添加鼠标移入事件
    box.addEventListener('mouseover', e => {
      const blocks = e.target
      //当鼠标移入小方块时，为其添加active类，并
      if(blocks.classList.contains('blockage')){
        blocks.classList.add('active')
        //随机设置小方块一个周期所耗时间
        const random = Math.random() * 5
        blocks.style.animationDuration = random + 's'
      }
    })
  </script>
</body>
</html>